﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>生产条码打印</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>
    <script type="text/html" id="barDemo">
      
               {{# if(d.isPrint=='Y'){}}
            <a title="条码打印" href="javascript:;" lay-event="print"><i class="layui-icon">&#xe66d;</i></a>
                {{# }}}
       
        @if (ViewData["operate"].ToString().Contains("replan"))
        {
            <a title="计划重启" href="javascript:;" lay-event="reset"><i class="layui-icon">&#xe667;</i></a>
        }
       {{# if(d.isPrint=='N'){}}
            <a title="生产报工" href="javascript:;" lay-event="scbg"><i class="layui-icon">&#xe705;</i></a>
    {{# }}}
    </script>

</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">
                                <select id="gxCode" name="gxCode" lay-filter="gx">
                                    <option value="">生产工序</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <select id="machine" name="machine" >
                                    <option value="">生产机台</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="proName" placeholder="存货名称" autocomplete="off" class="layui-input" id="proName">
                            </div>

                            <div class="layui-inline layui-show-xs-block">
                                <input type="text" name="proCode" placeholder="存货编码" autocomplete="off" class="layui-input" id="proCode">
                            </div>

                            <div class="layui-inline layui-show-xs-block">

                                <select id="machine" name="machine">
                                    <option value="">计划状态</option>
                                    <option value="pro-doing">进行中</option>
                                    <option value="do-finish">生产完成</option>
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-filter="sreach" id="userSearch" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                            </div>

                        </form>
                    </div>

                    <div class="layui-table-main" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>

<script>
    var currPage = 1;
    /**
    加载数据信息
    **/
    function loadData() {
        var ptype = $("#process").val();
        layui.use('table', function () {
            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
            , cols: [[ //标题栏
               { field: 'orNum', title: '计划编码', width: 90 }
             , { field: 'plCode', title: '派工序号', width: 120 }
             , { field: 'proCode', title: '存货编码', width: 100 }
             , { field: 'proName', title: '存货名称', width: 100 }
             , { field: 'gxName', title: '生产工序', width: 120 }
             , { field: 'groupName', title: '生产班组', width: 110 }
             , { field: 'sDate', title: '开工时间', width: 130 }
             , { field: 'number', title: '派工数量', width: 110 }
             , { field: 'fnumber', title: '完成数', width: 110 }
             , { field: 'createtime', title: '创建时间', width: 150 }
             , { field: 'memo', title: '备注说明', width: 150 }
             , { field: 'right', title: '操作', toolbar: '#barDemo', width: 100, fixed: 'right' }
            ]], done: function (res, curr, count) {
                $("[data-field='id']").css('display', 'none');//隐藏列
                currPage = curr;
                $.each(res['data'], function (i, j) {
                    if (j['isFinish'] == "1") {
                        TableRowColor('layui-table-main', i, '#FFD700');
                    }
                });
            }
            , url: "../Plan/getDataList?dataType=ppb&condition=" + conditon
            , skin: 'row' //表格风格
            , even: true
            , page: true //是否显示分页
            , limits: [20, 30, 50]
            , limit: 30 //每页默认显示的数量
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                if (obj.event == 'print') {
                    if (data['isFinish'] == "1") {
                        layer.msg("计划已完成,禁止生产打码"); return;
                    }
                    var win ="plan-bar-print";
                    SSO(win, JSON.stringify(data));

                }else if (obj.event == 'reset') {
                    if (data['isFinish'] != "1") {
                        layer.msg("该计划无需重启"); return;
                    }
                    layer.confirm('确认要重新开启该计划？', function (index) {
                        $.ajax({
                            url: "../Plan/OpenPlanStatus",
                            data: { ptCode: data.ptCode },
                            dataType: "json",
                            async: false,
                            type: "POST",
                            success: function (rsl) {
                                if (rsl.Result) {
                                    loadData();
                                } else {
                                    layer.msg(rsl.Message);
                                }
                                layer.close(index);
                            }
                        });

                    });
                } else if (obj.event == "scbg") {
                    if (data['isFinish'] == "1") {
                        layer.msg("计划已完成,禁止报工"); return;
                    }
                    var info = "?plCode=" + data.plCode + "&proCode=" + data.proCode + "&dataId=" + data.id + "&proName=" + data.proName +
                        "&groupCode=" + data.groupCode + "&gxCode=" + data.gxCode;
                    NewOpenPage("../Plan/ProBaoGong" + info, "生产报工(" + data.proName + ")", "80%", "80%", "", currPage, "");
                }
            });

        });
    }
    $(function () {
        CommonData("Gx", "gxCode", "");
        layui.use('form', function () {
            var form = layui.form;
            form.on('select(gx)', function (data) {
                if (data.value != "") {
                    GongXuMachine(data.value, "machine","");
                }
              
            });
        });
        loadData();
    })
 

</script>